﻿using System;
using System.Globalization;

namespace RecorderWorkerRole
{
    public class CustomDatesFormatter
    {
        public static string GetPrintable(TimeSpan iSpan)
        {
            string aFormatSpecifier = "{0:";
            if (iSpan.Hours > 0)
            {
                aFormatSpecifier += "hh\\h";
            }
            aFormatSpecifier += "mm"; //minutes specifier is obligatory
            if (iSpan.Seconds > 0)
            {
                aFormatSpecifier += "\\.ss";
            }
            aFormatSpecifier += "}";
            // 
            return String.Format(new CultureInfo("de-DE"), aFormatSpecifier, iSpan);
        }

        public static string GetPrintable(DateTime iDateTime)
        {
            string aFormatSpecifier = "{0:HH\\hmm";
            if (iDateTime.Second > 0)
            {
                aFormatSpecifier += "\\.ss";
            }
            aFormatSpecifier += " UTC, dd\\.MM\\.yy}";
            return String.Format(new CultureInfo("de-DE"), aFormatSpecifier, iDateTime);
        }
    }
}